/**
 * 机器人服务
 */
const robot = require('../api/baidu/robot');
const skill = require('../api/baidu/skill');

 /**
  * 与某个机器人聊天接口
  */
 exports.chatToRobot = ({message, botId, serviceId, sessonId, userId}) => {
     return new Promise((resovle, reject) => {
        robot({query : message, botId, serviceId, sessonId, userId})
            .then((json = {}) => {
                if(json.result == 0) {
                    resovle(json);
                }
                resovle(null);
            })
            .catch(e => {
                reject(e + '');
            });
     });
 };

 /**
  * 与单个技能聊天
  */
 exports.chatToSkill = ({message, botId, serviceId, sessonId, userId}) => {
    return new Promise((resovle, reject) => {
        skill({query : message, botId, serviceId, sessonId, userId})
            .then((json = {}) => {
                if(json.result == 0) {
                    resovle(json);
                }
                resovle(null);
            })
            .catch(e => {
                reject(e + '');
            });
     });
 };